package com.zhongkun.datahome.framework.manager;

import com.zhongkun.datahome.common.utils.spring.SpringUtils;
import org.springframework.core.task.AsyncTaskExecutor;

import java.util.TimerTask;

/**
 * 异步任务管理器
 * 
 * @author ruoyi
 */
public class AsyncManager
{

    /**
     * 单例模式
     */
    private AsyncManager(){}

    private static AsyncManager me = new AsyncManager();

    public static AsyncManager me()
    {
        return me;
    }

    /**
     * 执行任务
     * 
     * @param task 任务
     */
    public void execute(TimerTask task)
    {
        AsyncTaskExecutor threadPoolTaskExecutor = SpringUtils.getBean("threadPoolTaskExecutor");
        threadPoolTaskExecutor.execute(task);
    }

}
